package com.ansion.basedb.storage;

import androidx.annotation.NonNull;

import com.ansion.basedb.storage.api.MMKVStorage;

import java.util.concurrent.ConcurrentHashMap;

@Deprecated
public class LiteStorageManager {
    private static LiteStorageManager INST = null;
    private final ConcurrentHashMap<String, MMKVStorage> storageMap = new ConcurrentHashMap<>();

    private LiteStorageManager() {
    }

    public static LiteStorageManager getInstance() {
        if (INST == null) {
            synchronized (LiteStorageManager.class) {
                if (INST == null) {
                    INST = new LiteStorageManager();
                }
            }
        }
        return INST;
    }

    public MMKVStorage getStorage(@NonNull String key,boolean encrypt){
        MMKVStorage storage = storageMap.get(key);
        if(storage == null){
            storage = new LiteStorageImpl(key,encrypt);
            storageMap.put(key,storage);
        }
        return storage;
    }

    public MMKVStorage getStorage(@NonNull String key){
        return getStorage(key,false);
    }




    public void  onLogout() {
        storageMap.clear();
    }

}
